package com.yoomiito.app.utils;

import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;

import com.yoomiito.app.Constant;
import com.yoomiito.app.MainActivity;
import com.yoomiito.app.base.App;
import com.yoomiito.app.base.BaseActivity;
import com.yoomiito.app.net.YmApi;
import com.yoomiito.app.share.ui.GoodsShareActivity;
import com.yoomiito.app.taobao.BaiChuanManagerModule;
import com.yoomiito.app.taobao.WebViewSqActivity;
import com.yoomiito.app.ui.goods.GoodsInfoActivity;
import com.yoomiito.app.ui.goods.NewGoodsInfoActivity;

import cn.droidlover.xdroidmvp.log.XLog;
import cn.droidlover.xdroidmvp.net.ApiException;
import cn.droidlover.xdroidmvp.net.ApiSubscriber;
import cn.droidlover.xdroidmvp.net.XApi;
import cn.droidlover.xdroidmvp.router.Router;

public class RouterUtils {

    public static void TaoBaoWithUrl(String url) {
//        BaiChuanManagerModule.getInstance().tbjumpWithUrl(url);
    }

    public static void TaoBaoWithUrl(String url, String clientType) {
//        BaiChuanManagerModule.getInstance().tbjumpWithUrl(url, clientType);
    }

    //淘宝授权
    public static void getTBAuthorization(BaseActivity context) {
        WebViewSqActivity.Companion.start(context);
    }

    public static void toShareGoods(BaseActivity context, String id, int goodsType) {
        switch (goodsType) {
            case AllCode.TaoBao:
                if (App.mAppConfig.getIsLogin() && TextUtils.isEmpty(UserInfoConfig.getRelationId())) {
                    WebViewSqActivity.Companion.start(context);
                    return;
                }
                break;

        }

        Router.newIntent(context)
                .to(GoodsShareActivity.class)
                .putString(Constant.ID, id)
                .putInt(Constant.TYPE, goodsType)
                .launch();
    }


    public static void toGoodsDetail(Context context, String id, int goodsType) {

        switch (goodsType) {
            case AllCode.TaoBao:
            case AllCode.FreeBuyGoods:
                if (App.mAppConfig.getIsLogin() && TextUtils.isEmpty(UserInfoConfig.getRelationId())) {
                    WebViewSqActivity.Companion.start(context);
                    return;
                }
                break;

        }
        switch (goodsType) {
            case AllCode.StarStore:
            case AllCode.FreeBuyGoods:
            case AllCode.AgentMall:
                GoodsInfoActivity.toGoodsInfo(context, id, goodsType);
                break;
            default:
                NewGoodsInfoActivity.Companion.toGoodsInfo(context, id, goodsType == AllCode.TaoBao ? "1" : "2");
                break;
        }
    }

    public static void toMain(Activity activity, int tab) {
        Router.newIntent(activity)
                .to(MainActivity.class)
                .putInt(Constant.ToFM, tab)
                .launch();
        activity.finish();
    }

}
